package com.autumn.zero.authorization.entitys.users;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.apache.ibatis.type.JdbcType;
import org.hibernate.validator.constraints.Length;

import com.autumn.constants.SettingConstants;
import com.autumn.domain.entities.AbstractDefaultEntity;
import com.autumn.mybatis.mapper.annotation.ColumnOrder;
import com.autumn.mybatis.mapper.annotation.ColumnType;
import com.autumn.mybatis.mapper.annotation.Index;
import com.autumn.validation.annotation.NotNullOrBlank;

/**
 * 用户外部授权登录
 * 
 * @author 杨昌国 2018-11-25 01:57:42
 */
@Table(name = SettingConstants.SYS_TABLE_PREFIX + "_user_external_auth_login")
public class UserExternalAuthLogin extends AbstractDefaultEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6750966862538795503L;

	/**
	 * 最大提供者长度
	 */
	public static final int MAX_PROVIDER_LENGTH = 128;

	/**
	 * 最大提供者键长度
	 */
	public static final int MAX_PROVIDER_KEY_LENGTH = 256;

	/**
	 * 字段 userId
	 */
	public static final String FILED_USER_ID = "userId";

	/**
	 * 字段 provider
	 */
	public static final String FILED_PROVIDER = "provider";

	/**
	 * 字段 providerKey
	 */
	public static final String FILED_PROVIDER_KEY = "providerKey";

	/**
	 * 用户id
	 */
	@NotNull(message = "用户id不能为空。")
	@Column(name = "user_id", nullable = false)
	@Index
	@ColumnOrder(1)
	private Long userId;

	/**
	 * 第三方提供者
	 */
	@NotNullOrBlank(message = "第三方提供者名称不能为空")
	@Length(max = MAX_PROVIDER_LENGTH, message = "第三方提供者名称长度不能超过" + MAX_PROVIDER_LENGTH + "个字。")
	@Column(name = "provider", nullable = false, length = MAX_PROVIDER_LENGTH)
	@ColumnType(jdbcType = JdbcType.VARCHAR)
	@Index
	@ColumnOrder(2)
	private String provider;

	/**
	 * 第三方提供者键
	 */
	@NotNullOrBlank(message = "第三方提供者键不能为空")
	@Length(max = MAX_PROVIDER_KEY_LENGTH, message = "第三方提供者键长度不能超过" + MAX_PROVIDER_KEY_LENGTH + "个字。")
	@Column(name = "provider_key", nullable = false, length = MAX_PROVIDER_KEY_LENGTH)
	@ColumnType(jdbcType = JdbcType.VARCHAR)
	@ColumnOrder(3)
	private String providerKey;

	/**
	 * 获取用户Id
	 * 
	 * @return
	 */
	public Long getUserId() {
		return userId;
	}

	/**
	 * 设置用户Id
	 * 
	 * @param userId 用户Id
	 */
	public void setUserId(Long userId) {
		this.userId = userId;
	}

	/**
	 * 获取提供者
	 * 
	 * @return
	 */
	public String getProvider() {
		return provider;
	}

	/**
	 * 设置提供者
	 * 
	 * @param provider 提供者
	 */
	public void setProvider(String provider) {
		this.provider = provider;
	}

	/**
	 * 获取提供者键
	 * 
	 * @return
	 */
	public String getProviderKey() {
		return providerKey;
	}

	/**
	 * 设置提供者键
	 * 
	 * @param providerKey 提供者键
	 */
	public void setProviderKey(String providerKey) {
		this.providerKey = providerKey;
	}

}
